﻿namespace UnityEditor
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEditorInternal;
    using UnityEngine;

    internal class AnimationWindow : EditorWindow, TimeUpdater, CurveUpdater
    {
        internal static PrefColor kAnimatedColor = new PrefColor("Testing/AnimatedObject", 0f, 0f, 0f, 0.3f);
        internal const int kAnimationHeight = 15;
        internal static PrefKey kAnimationNextFrame = new PrefKey("Animation/Next Frame", ".");
        internal static PrefKey kAnimationNextKeyframe = new PrefKey("Animation/Next Keyframe", "&.");
        internal static PrefKey kAnimationPrevFrame = new PrefKey("Animation/Previous Frame", ",");
        internal static PrefKey kAnimationPrevKeyframe = new PrefKey("Animation/Previous Keyframe", "&,");
        internal static PrefKey kAnimationRecordKeyframe = new PrefKey("Animation/Record Keyframe", "k");
        internal const int kButtonWidth = 30;
        internal static PrefColor kEulerXColor = new PrefColor("Testing/EulerX", 1f, 0f, 1f, 1f);
        internal static PrefColor kEulerYColor = new PrefColor("Testing/EulerY", 1f, 1f, 0f, 1f);
        internal static PrefColor kEulerZColor = new PrefColor("Testing/EulerZ", 0f, 1f, 1f, 1f);
        internal static bool kEvenRow;
        internal const int kEventLineHeight = 15;
        internal const int kHierarchyAnimationSpacingHeight = 15;
        internal const int kHierarchyComponentHeight = 15;
        internal const int kHierarchyFieldWidth = 0x2d;
        internal const int kHierarchyGameobjectHeight = 15;
        internal const int kHierarchyIconButtonWidth = 0x16;
        internal const int kHierarchyIconHeight = 11;
        internal const int kHierarchyIconWidth = 11;
        internal const int kHierarchyLeftMargin = 2;
        internal const int kHierarchyPropertyHeight = 12;
        internal const int kIntFieldWidth = 0x23;
        internal const int kKeyframeLineHeight = 15;
        internal const int kTickRulerDistFull = 80;
        internal const int kTickRulerDistLabel = 40;
        internal const int kTickRulerDistMin = 3;
        internal const float kTickRulerFatThreshold = 0.5f;
        internal const float kTickRulerHeightMax = 0.7f;
        internal const int kTimeLineHeight = 0x11;
        private bool m_ActuallyMoved;
        private bool m_AutoRecord;
        [SerializeField]
        private SerializedStringTable m_ChosenAnimated;
        [SerializeField]
        private SerializedStringTable m_ChosenClip;
        private CurveEditor m_CurveEditor;
        private bool m_DirtyCurves = true;
        private bool m_DirtyProperties = true;
        [NonSerialized]
        private bool m_DirtyPropertyList = true;
        private bool m_DirtyTooltip;
        private int[] m_EditedCurves = new int[0];
        private Rect[] m_EventRects = new Rect[0];
        private static AnimationEvent[] m_EventsAtMouseDown;
        private bool[] m_EventsSelected;
        private static float[] m_EventTimes;
        [SerializeField]
        private SerializedStringTable m_ExpandedFoldouts;
        private int m_FinalFrame = 120;
        private int m_Frame;
        private float m_FrameRate = 60f;
        private GameObjectAndHierarchyChangeTracker m_GameObjectAndHierarchyChangeTracker;
        private int m_HoverEvent = -1;
        private int m_HoverRect = -1;
        private Material[] m_InstantiatedMaterials;
        private Vector2 m_InstantTooltipPoint = Vector2.zero;
        private string m_InstantTooltipText;
        private Rect[] m_KeyframeRects = new Rect[0];
        private int[] m_Keyframes;
        private bool[] m_KeyframesReadOnly;
        private bool[] m_KeyframesSelected;
        private CurveMenuManager m_MenuManager;
        private bool m_PerformFrameSelected = true;
        private bool m_PlayFromNoMode;
        private bool m_PlayMode;
        private float m_PlayTime;
        private float m_PrevRealTime;
        private Rect[] m_PropertyFieldRects = new Rect[0];
        private Rect[] m_PropertyIconRects = new Rect[0];
        private Vector2 m_PropertyViewScroll;
        private bool m_RemoveTextFieldFocus;
        private AnimationSelection[] m_Selected;
        [NonSerialized]
        private bool[] m_SelectedProperties = new bool[0];
        [SerializeField]
        private bool m_ShowAllProperties = true;
        [NonSerialized]
        private CurveState[] m_ShownProperties = new CurveState[0];
        private SplitterState m_Splitter;
        private ZoomableArea m_TimeLineArea;
        private bool m_UndoPending;
        internal static Styles ms_Styles;
        private static int s_AnimationTextFieldHash = "AnimationTextField".GetHashCode();
        internal static int s_StartDragFrame = 0;
        internal static int vPosition;

        public AnimationWindow()
        {
            EditorApplication.onAnimationClipAwake = (EditorApplication.AnimationClipAwake) Delegate.Combine(EditorApplication.onAnimationClipAwake, new EditorApplication.AnimationClipAwake(this.OnAnimationClipAwake));
            EditorApplication.undoRedoPerformed = (EditorApplication.CallbackFunction) Delegate.Combine(EditorApplication.undoRedoPerformed, new EditorApplication.CallbackFunction(this.UndoRedoPerformed));
        }

        public void AddCurve(CurveState curveState, int frame)
        {
            if (!curveState.animated)
            {
                float num;
                CurveUtility.GetFloatValue(curveState.animationSelection.animatedObject, curveState.curveData.path, curveState.curveData.type, curveState.curveData.propertyName, out num);
                this.AddCurve(curveState, frame, num);
            }
        }

        public void AddCurve(CurveState curveState, int frame, float val)
        {
            if (!curveState.animated && curveState.animationSelection.EnsureClipPresence())
            {
                AnimationCurve curve = new AnimationCurve();
                int index = curve.AddKey(this.FrameToTime((float) frame), val);
                Keyframe key = curve[index];
                CurveUtility.SetKeyTangentMode(ref key, 0, TangentMode.Smooth);
                CurveUtility.SetKeyTangentMode(ref key, 1, TangentMode.Smooth);
                curve.MoveKey(index, key);
                curveState.animated = true;
                Undo.RegisterUndo(curveState.clip, "Add Curves");
                curveState.SaveCurve(curve);
                GUI.changed = true;
                this.SetDirtyProperties();
            }
        }

        public void AddCurves(object obj)
        {
            this.AddCurves(((List<int>) obj).ToArray(), this.m_Frame);
            this.Refresh();
            this.ResampleAnimation();
        }

        public void AddCurves(int[] indices, int frame)
        {
            foreach (int num in indices)
            {
                this.AddCurve(this.m_ShownProperties[num], frame);
            }
        }

        private void AddKeysAtTime(object obj)
        {
            this.RecordKeyframe(((List<int>) obj).ToArray(), this.m_Frame, false);
        }

        public bool AllHaveClips()
        {
            foreach (AnimationSelection selection in this.m_Selected)
            {
                if (selection.clip == null)
                {
                    return false;
                }
            }
            return true;
        }

        private void AnimationControls()
        {
            Event current = Event.current;
            switch (current.type)
            {
                case EventType.KeyDown:
                    if (kAnimationPrevFrame.activated)
                    {
                        this.PreviewFrame(Mathf.Max(0, this.m_Frame - 1));
                        current.Use();
                    }
                    if (kAnimationNextFrame.activated)
                    {
                        this.PreviewFrame(this.m_Frame + 1);
                        current.Use();
                    }
                    if (kAnimationPrevKeyframe.activated)
                    {
                        this.Prev();
                        current.Use();
                    }
                    if (kAnimationNextKeyframe.activated)
                    {
                        this.Next();
                        current.Use();
                    }
                    if (kAnimationRecordKeyframe.activated)
                    {
                        this.RecordKeyframe(this.GetShownOrSelectedProperties(), this.m_Frame, true);
                        this.PreviewFrame(this.m_Frame);
                        current.Use();
                    }
                    break;
            }
        }

        private void AnimationTextField(Rect position, float curValue, int index)
        {
            float num3;
            CurveState state = this.m_ShownProperties[index];
            int id = EditorGUI.GetControlID(s_AnimationTextFieldHash, FocusType.Keyboard, position);
            int keyboardControl = GUIUtility.keyboardControl;
            bool flag = false;
            if (id == GUIUtility.keyboardControl)
            {
                if (this.m_RemoveTextFieldFocus)
                {
                    GUIUtility.keyboardControl = 0;
                }
                else
                {
                    Event current = Event.current;
                    if (current.type == EventType.KeyDown)
                    {
                        KeyCode keyCode = current.keyCode;
                        if (keyCode != KeyCode.Return)
                        {
                            if (keyCode == KeyCode.Escape)
                            {
                                GUIUtility.keyboardControl = 0;
                                Undo.PerformUndo();
                                current.Use();
                                return;
                            }
                            if (keyCode != KeyCode.KeypadEnter)
                            {
                                goto Label_00A6;
                            }
                        }
                        flag = true;
                        GUIUtility.keyboardControl = 0;
                        current.Use();
                    }
                }
            }
        Label_00A6:
            num3 = EditorGUI.DoFloatField(EditorGUI.s_RecycledEditor, position, new Rect(0f, 0f, 0f, 0f), id, curValue, EditorGUI.kFloatFieldFormatString, "AnimationSelectionTextField", false);
            if ((GUIUtility.keyboardControl == id) && (keyboardControl != id))
            {
                this.m_UndoPending = true;
            }
            if (((num3 != curValue) || flag) && this.EnsureAnimationMode())
            {
                if (this.m_UndoPending)
                {
                    this.m_UndoPending = false;
                    Undo.RegisterUndo(state.clip, "Key Value Edit");
                }
                if (state.animationSelection.EnsureClipPresence())
                {
                    int[] indices = new int[] { index };
                    this.RecordKeyframe(this.GetLinkedProperties(indices, true), this.m_Frame, false);
                    CurveRenderer curveRenderer = CurveUtility.GetCurveRenderer(state.clip, state.curveData);
                    CurveUtility.AddOrReplaceKey(curveRenderer, this.time, num3, this.timeFloor, this.timeCeiling);
                    state.SaveCurve(curveRenderer.GetCurve());
                    this.SetDirtyProperties();
                    GUI.changed = true;
                }
            }
            if ((GUIUtility.keyboardControl != id) && (keyboardControl == id))
            {
                this.m_UndoPending = false;
            }
        }

        private bool AnyPropertiesSelected()
        {
            bool[] selectedProperties = this.m_SelectedProperties;
            for (int i = 0; i < selectedProperties.Length; i++)
            {
                if (selectedProperties[i])
                {
                    return true;
                }
            }
            return false;
        }

        private bool AreLinked(int i, int j, bool onlyLinkEuler)
        {
            if (i == j)
            {
                return false;
            }
            if (!this.IsLinked(this.m_ShownProperties[i], onlyLinkEuler))
            {
                return false;
            }
            return (this.m_ShownProperties[i].GetGroupID() == this.m_ShownProperties[j].GetGroupID());
        }

        private bool AreSameProperties(CurveState[] oldList, CurveState[] newList)
        {
            bool flag = true;
            if (oldList.Length != newList.Length)
            {
                flag = false;
            }
            for (int i = 0; (i < oldList.Length) && flag; i++)
            {
                if (newList[i].animated != oldList[i].animated)
                {
                    return false;
                }
                if ((newList[i].animated && oldList[i].animated) && (newList[i].clip != oldList[i].clip))
                {
                    return false;
                }
                if (((newList[i].curveData.propertyName != oldList[i].curveData.propertyName) || (newList[i].curveData.path != oldList[i].curveData.path)) || (newList[i].curveData.target != oldList[i].curveData.target))
                {
                    return false;
                }
            }
            return flag;
        }

        public void Awake()
        {
            base.minSize = new Vector2(400f, 200f);
            float[] relativeSizes = new float[] { 250f, 10000f };
            int[] minSizes = new int[] { 250, 150 };
            this.m_Splitter = new SplitterState(relativeSizes, minSizes, null);
            this.m_Splitter.realSizes[0] = 250;
            base.wantsMouseMove = true;
            this.m_Selected = new AnimationSelection[0];
            if (this.m_ExpandedFoldouts == null)
            {
                this.m_ExpandedFoldouts = new SerializedStringTable();
            }
            if (this.m_ChosenAnimated == null)
            {
                this.m_ChosenAnimated = new SerializedStringTable();
            }
            if (this.m_ChosenClip == null)
            {
                this.m_ChosenClip = new SerializedStringTable();
            }
            this.m_CurveEditor = new CurveEditor(new Rect(base.position.x, base.position.y, 500f, 400f), new CurveWrapper[0], false);
            this.SetGridColors();
            this.m_CurveEditor.m_TimeUpdater = this;
            this.m_CurveEditor.m_DefaultBounds = new Bounds(new Vector3(1f, 1f, 0f), new Vector3(2f, 1000f, 0f));
            this.m_CurveEditor.SetShownHRangeInsideMargins(0f, 2f);
            this.m_TimeLineArea = new ZoomableArea(false);
            this.m_TimeLineArea.hRangeLocked = false;
            this.m_TimeLineArea.vRangeLocked = true;
            this.m_TimeLineArea.hSlider = false;
            this.m_TimeLineArea.vSlider = false;
            this.m_CurveEditor.hTicks.SetTickModulosForFrameRate(this.m_FrameRate);
            this.InitSelection();
        }

        public bool BeginAnimationMode(bool askUserIfMissingClips)
        {
            if ((this.m_Selected.Length == 0) || !this.m_Selected[0].GameObjectIsAnimatable)
            {
                return false;
            }
            if (!askUserIfMissingClips && !this.AllHaveClips())
            {
                return false;
            }
            if (askUserIfMissingClips && !this.EnsureAllHaveClips())
            {
                return false;
            }
            List<UnityEngine.Object> list = new List<UnityEngine.Object>();
            foreach (AnimationSelection selection in this.m_Selected)
            {
                UnityEngine.Object gameObject = selection.animatedObject.transform.root.gameObject;
                if (!list.Contains(gameObject))
                {
                    list.Add(gameObject);
                }
            }
            UnityEngine.Object[] objects = EditorUtility.CollectDeepHierarchy(list.ToArray());
            AnimationUtility.StartAnimationMode(objects);
            foreach (UnityEngine.Object obj3 in objects)
            {
                UnityEngine.Renderer renderer = obj3 as UnityEngine.Renderer;
                if (renderer != null)
                {
                    this.m_InstantiatedMaterials = InternalEditorUtility.InstantiateMaterialsInEditMode(renderer);
                }
            }
            this.ResampleAnimation();
            this.SetAutoRecordMode(true);
            this.SetDirtyProperties();
            Tools.RepaintAllToolViews();
            return true;
        }

        private string BoolArrayString(bool[] array)
        {
            string str = string.Empty;
            foreach (bool flag in array)
            {
                str = str + (!flag ? "-" : "1");
            }
            return str;
        }

        private void CalculateEditedCurves()
        {
            bool flag = this.AnyPropertiesSelected();
            List<int> list = new List<int>();
            for (int i = 0; i < this.m_ShownProperties.Length; i++)
            {
                if (this.m_ShownProperties[i].animated && (!flag || this.m_SelectedProperties[i]))
                {
                    list.Add(i);
                }
            }
            this.m_EditedCurves = this.GetLinkedProperties(list.ToArray(), true);
        }

        public void ChangeRotationInterpolationType(List<int> propertyIndices, bool useBaked)
        {
            List<int> list = new List<int>();
            List<AnimationCurve> list2 = new List<AnimationCurve>();
            List<CurveRenderer> list3 = new List<CurveRenderer>();
            foreach (int num in propertyIndices)
            {
                CurveState state = this.m_ShownProperties[num];
                if (state.animated && (state.curveData.propertyName.StartsWith("localEulerAngles.") == useBaked))
                {
                    if (useBaked)
                    {
                        Undo.RegisterUndo(state.clip, "Euler Angles Interpolation");
                    }
                    else
                    {
                        Undo.RegisterUndo(state.clip, "Quaternion Interpolation");
                    }
                    list.Add(num);
                    list2.Add(state.curve);
                    state.SaveCurve(null);
                    string propertyName = state.curveData.propertyName;
                    if (useBaked)
                    {
                        state.curveData.propertyName = "localEulerAnglesBaked." + propertyName.Substring(propertyName.Length - 1, 1);
                    }
                    else
                    {
                        state.curveData.propertyName = "localEulerAngles." + propertyName.Substring(propertyName.Length - 1, 1);
                    }
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                this.m_ShownProperties[list[i]].SaveCurve(list2[i]);
            }
            CurveUtility.ClearCurveRendererCache();
            for (int j = 0; j < list.Count; j++)
            {
                CurveState state3 = this.m_ShownProperties[list[j]];
                CurveRenderer curveRenderer = CurveUtility.GetCurveRenderer(state3.clip, state3.curveData);
                list3.Add(curveRenderer);
                CurveUtility.UpdateAllTangentsFromMode(curveRenderer);
            }
            if (!useBaked)
            {
                CurveUtility.SyncCurves(list3.ToArray());
            }
            for (int k = 0; k < list.Count; k++)
            {
                CurveState state4 = this.m_ShownProperties[list[k]];
                CurveUtility.UpdateAllTangentsFromMode(list3[k]);
                state4.SaveCurve(list3[k].GetCurve());
            }
            GUI.changed = true;
            this.SetDirtyProperties();
        }

        private void CheckContextClick(Rect rect, int index)
        {
            Event current = Event.current;
            if ((current.type == EventType.ContextClick) && rect.Contains(current.mousePosition))
            {
                int[] affectedProperties = this.GetAffectedProperties(index, false);
                int[] keyLinked = this.GetAffectedProperties(index, true);
                this.GenerateMenu(affectedProperties, keyLinked).ShowAsContext();
                Event.current.Use();
            }
        }

        private void CheckRectsOnMouseMove(Rect eventLineRect, Rect keyframeLineRect)
        {
            Vector2 mousePosition = Event.current.mousePosition;
            int num = -1;
            if (this.m_DirtyTooltip)
            {
                this.m_HoverRect = -1;
            }
            this.m_DirtyTooltip = false;
            this.m_HoverEvent = -1;
            if (eventLineRect.Contains(mousePosition))
            {
                for (int i = this.m_EventRects.Length - 1; i >= 0; i--)
                {
                    if (this.m_EventRects[i].Contains(mousePosition))
                    {
                        num = i;
                        this.m_HoverEvent = i;
                        break;
                    }
                }
            }
            else
            {
                for (int j = this.m_PropertyIconRects.Length - 1; j >= 0; j--)
                {
                    if (this.m_PropertyIconRects[j].Contains(mousePosition))
                    {
                        num = this.m_EventRects.Length + j;
                        break;
                    }
                    if (this.m_PropertyFieldRects[j].Contains(mousePosition))
                    {
                        num = (this.m_EventRects.Length + this.m_PropertyIconRects.Length) + j;
                        break;
                    }
                }
            }
            if (num != this.m_HoverRect)
            {
                this.m_HoverRect = num;
                this.m_DirtyTooltip = true;
                this.m_InstantTooltipText = null;
            }
        }

        private void ClearShownProperties()
        {
            this.m_ShownProperties = new CurveState[0];
            this.m_SelectedProperties = new bool[0];
            CurveUtility.ClearCurveRendererCache();
        }

        private void DebugTime(string str, float timeA, float timeB)
        {
            Debug.Log(str + " took " + (timeB - timeA));
        }

        public void DeleteCurve(CurveState curveState)
        {
            if (curveState.animated)
            {
                curveState.animated = false;
                Undo.RegisterUndo(curveState.clip, "Delete Curves");
                curveState.SaveCurve(null);
                CurveUtility.ClearCurveRendererCache();
                GUI.changed = true;
                this.SetDirtyProperties();
            }
        }

        public void DeleteCurves(object obj)
        {
            this.DeleteCurves(((List<int>) obj).ToArray());
            this.ReEnterAnimationMode();
            this.Refresh();
            this.ResampleAnimation();
        }

        public void DeleteCurves(int[] indices)
        {
            foreach (int num in indices)
            {
                this.DeleteCurve(this.m_ShownProperties[num]);
            }
        }

        private void DeleteEvents(AnimationClip clip, bool[] deleteIndices)
        {
            bool flag = false;
            List<AnimationEvent> list = new List<AnimationEvent>(AnimationUtility.GetAnimationEvents(clip));
            for (int i = list.Count - 1; i >= 0; i--)
            {
                if (deleteIndices[i])
                {
                    list.RemoveAt(i);
                    flag = true;
                }
            }
            if (flag)
            {
                AnimationEventPopup.ClosePopup();
                Undo.RegisterUndo(clip, "Delete Event");
                AnimationUtility.SetAnimationEvents(clip, list.ToArray());
                this.m_EventsSelected = new bool[list.Count];
                this.SetDirtyProperties();
                this.m_DirtyTooltip = true;
            }
        }

        private void DeleteKeyframe(int[] indices, int frame)
        {
            if (this.EnsureAnimationMode())
            {
                this.DoDelete(indices, frame);
                this.SetDirtyProperties();
            }
        }

        public void DeleteKeyframes(bool[] deleteIndices)
        {
            Undo.RegisterUndo(this.m_CurveEditor.m_UndoObjects, "Delete Keys");
            for (int i = this.m_Keyframes.Length - 1; i >= 0; i--)
            {
                if (deleteIndices[i])
                {
                    this.DeleteKeyframe(this.m_EditedCurves, this.m_Keyframes[i]);
                }
            }
        }

        private void DeleteKeysAtTime(object obj)
        {
            this.DeleteKeyframe(((List<int>) obj).ToArray(), this.m_Frame);
        }

        private void DoDelete(int[] indices, int frame)
        {
            if (this.m_Selected[0].CanClipAndGameObjectBeEdited)
            {
                foreach (int num in indices)
                {
                    CurveState state = this.m_ShownProperties[num];
                    if (state.animated)
                    {
                        AnimationCurve curve = state.curve;
                        if (CurveUtility.HaveKeysInRange(curve, this.FrameToTimeFloor((float) frame), this.FrameToTimeCeiling((float) frame)))
                        {
                            Undo.RegisterUndo(state.clip, "Delete Keyframe");
                            CurveUtility.RemoveKeysInRange(curve, this.FrameToTimeFloor((float) frame), this.FrameToTimeCeiling((float) frame));
                            state.SaveCurve(curve);
                        }
                    }
                }
            }
        }

        private void DoRecord(int[] indices, int frame, bool overwriteExisting)
        {
            if ((this.m_Selected[0].GameObjectIsAnimatable && this.m_Selected[0].EnsureClipPresence()) && this.m_Selected[0].CanClipAndGameObjectBeEdited)
            {
                foreach (int num in indices)
                {
                    CurveState curveState = this.m_ShownProperties[num];
                    Undo.RegisterUndo(curveState.clip, "Record Keyframe");
                    float sampledOrCurveValue = curveState.GetSampledOrCurveValue(this.FrameToTime((float) frame));
                    if (!curveState.animated)
                    {
                        this.AddCurve(curveState, frame, sampledOrCurveValue);
                    }
                    CurveRenderer curveRenderer = CurveUtility.GetCurveRenderer(curveState.clip, curveState.curveData);
                    AnimationCurve curve = curveRenderer.GetCurve();
                    if (overwriteExisting || !CurveUtility.HaveKeysInRange(curve, this.FrameToTimeFloor((float) frame), this.FrameToTimeCeiling((float) frame)))
                    {
                        CurveUtility.AddOrReplaceKey(curveRenderer, this.FrameToTime((float) frame), sampledOrCurveValue, this.FrameToTimeFloor((float) frame), this.FrameToTimeCeiling((float) frame));
                        curveState.SaveCurve(curve);
                    }
                }
            }
        }

        public void DrawClipsInSceneView()
        {
        }

        private void DrawInstantTooltip()
        {
            if ((this.m_InstantTooltipText != null) && (this.m_InstantTooltipText != string.Empty))
            {
                GUIStyle style = "AnimationEventTooltip";
                Vector2 vector = style.CalcSize(new GUIContent(this.m_InstantTooltipText));
                Rect position = new Rect(this.m_InstantTooltipPoint.x - 10f, this.m_InstantTooltipPoint.y + 24f, vector.x, vector.y);
                if (position.xMax > base.position.width)
                {
                    position.x = base.position.width - position.width;
                }
                GUI.Label(position, this.m_InstantTooltipText, style);
                position = new Rect(this.m_InstantTooltipPoint.x - 3f, this.m_InstantTooltipPoint.y, 7f, 25f);
                GUI.Label(position, string.Empty, "AnimationEventTooltipArrow");
            }
        }

        internal void DrawRowBackground(int width, int height)
        {
            this.DrawRowBackground(width, height, false);
        }

        internal void DrawRowBackground(int width, int height, bool selected)
        {
            kEvenRow = !kEvenRow;
            (!kEvenRow ? ms_Styles.rowOdd : ms_Styles.rowEven).Draw(new Rect(0f, (float) vPosition, (float) width, (float) height), false, false, selected, false);
        }

        public void EndAnimationMode()
        {
            if (AnimationUtility.InAnimationMode())
            {
                if (this.m_PlayMode)
                {
                    this.Stop();
                }
                this.m_Frame = 0;
                if (this.m_InstantiatedMaterials != null)
                {
                    foreach (Material material in this.m_InstantiatedMaterials)
                    {
                        UnityEngine.Object.DestroyImmediate(material);
                    }
                    this.m_InstantiatedMaterials = null;
                }
                AnimationUtility.StopAnimationMode();
                this.SetDirtyProperties();
                Tools.RepaintAllToolViews();
            }
        }

        public static void EndAnimationModeForAllViews()
        {
            foreach (UnityEngine.Object obj2 in Resources.FindObjectsOfTypeAll(typeof(AnimationWindow)))
            {
                (obj2 as AnimationWindow).EndAnimationMode();
            }
        }

        public bool EnsureAllHaveClips()
        {
            foreach (AnimationSelection selection in this.m_Selected)
            {
                if (!selection.EnsureClipPresence())
                {
                    return false;
                }
            }
            return true;
        }

        public bool EnsureAnimationMode()
        {
            return (AnimationUtility.InAnimationMode() || this.BeginAnimationMode(true));
        }

        private bool EvaluateFramerate()
        {
            if (this.m_Selected.Length == 0)
            {
                this.m_FrameRate = Mathf.Abs(this.m_FrameRate);
                return true;
            }
            float num = Mathf.Abs(this.m_FrameRate);
            int num2 = 0;
            float a = 0f;
            bool flag = true;
            foreach (AnimationSelection selection in this.m_Selected)
            {
                if (selection.clip != null)
                {
                    a = Mathf.Max(a, selection.clip.length);
                    if (num2 == 0)
                    {
                        num2 = Mathf.RoundToInt(selection.clip.frameRate);
                    }
                    else if (selection.clip.frameRate != num2)
                    {
                        flag = false;
                        break;
                    }
                }
            }
            if (num2 == 0)
            {
                num2 = 60;
            }
            if (!flag)
            {
                this.m_FrameRate = -num;
                return false;
            }
            this.m_FrameRate = num2;
            this.m_FinalFrame = Mathf.RoundToInt(a * Mathf.Abs(this.m_FrameRate));
            float num5 = this.m_FrameRate / num;
            this.m_Frame = Mathf.RoundToInt(num5 * this.m_Frame);
            this.m_CurveEditor.hTicks.SetTickModulosForFrameRate(this.m_FrameRate);
            return true;
        }

        public void EventLineContextMenuAdd(object obj)
        {
            EventLineContextMenuObject obj2 = (EventLineContextMenuObject) obj;
            int index = AnimationEventPopup.Create(obj2.m_Animated, obj2.m_Clip, obj2.m_Time);
            this.m_EventsSelected = new bool[AnimationUtility.GetAnimationEvents(obj2.m_Clip).Length];
            this.m_EventsSelected[index] = true;
            this.SetDirtyProperties();
        }

        public void EventLineContextMenuDelete(object obj)
        {
            if ((this.m_Selected.Length != 0) && (this.m_Selected[0].clip != null))
            {
                AnimationClip clip = this.m_Selected[0].clip;
                int index = (int) obj;
                if (this.m_EventsSelected[index])
                {
                    this.DeleteEvents(clip, this.m_EventsSelected);
                }
                else
                {
                    bool[] deleteIndices = new bool[this.m_EventsSelected.Length];
                    deleteIndices[index] = true;
                    this.DeleteEvents(clip, deleteIndices);
                }
            }
        }

        private void EventLineGUI(Rect rect, AnimationSelection selection)
        {
            if (!selection.CanClipAndGameObjectBeEdited)
            {
                GUI.enabled = false;
            }
            AnimationClip clip = selection.clip;
            GameObject animatedObject = selection.animatedObject;
            GUI.BeginGroup(rect);
            Color color = GUI.color;
            Rect rect2 = new Rect(0f, 0f, rect.width, rect.height);
            if (((Event.current.type == EventType.MouseDown) && (Event.current.clickCount == 2)) && (rect2.Contains(Event.current.mousePosition) && selection.EnsureClipPresence()))
            {
                Event.current.Use();
                float time = ((float) Mathf.RoundToInt(this.PixelToTime(Event.current.mousePosition.x, rect) * this.m_FrameRate)) / this.m_FrameRate;
                int index = AnimationEventPopup.Create(animatedObject, selection.clip, time);
                this.m_EventsSelected = new bool[AnimationUtility.GetAnimationEvents(selection.clip).Length];
                this.m_EventsSelected[index] = true;
                this.SetDirtyProperties();
            }
            if (clip != null)
            {
                int num10;
                float num11;
                float num12;
                AnimationEvent[] animationEvents = AnimationUtility.GetAnimationEvents(clip);
                Texture image = EditorGUIUtility.IconContent("Animation.EventMarker").image;
                Rect[] hitPositions = new Rect[animationEvents.Length];
                Rect[] positions = new Rect[animationEvents.Length];
                int num3 = 1;
                int num4 = 0;
                for (int i = 0; i < animationEvents.Length; i++)
                {
                    AnimationEvent event2 = animationEvents[i];
                    if (num4 == 0)
                    {
                        num3 = 1;
                        while (((i + num3) < animationEvents.Length) && (animationEvents[i + num3].time == event2.time))
                        {
                            num3++;
                        }
                        num4 = num3;
                    }
                    num4--;
                    float num6 = Mathf.Floor(this.FrameToPixel(event2.time * clip.frameRate, rect));
                    int num7 = 0;
                    if (num3 > 1)
                    {
                        float num8 = Mathf.Min((int) ((num3 - 1) * (image.width - 1)), (int) (((int) this.FrameDeltaToPixel(rect)) - (image.width * 2)));
                        num7 = Mathf.FloorToInt(Mathf.Max((float) 0f, (float) (num8 - ((image.width - 1) * num4))));
                    }
                    Rect rect3 = new Rect((num6 + num7) - (image.width / 2), ((rect.height - 10f) * ((num4 - num3) + 1)) / ((float) Mathf.Max(1, num3 - 1)), (float) image.width, (float) image.height);
                    hitPositions[i] = rect3;
                    positions[i] = rect3;
                }
                this.m_EventRects = new Rect[hitPositions.Length];
                for (int j = 0; j < hitPositions.Length; j++)
                {
                    this.m_EventRects[j] = new Rect(hitPositions[j].x + rect.x, hitPositions[j].y + rect.y, hitPositions[j].width, hitPositions[j].height);
                }
                if (this.m_DirtyTooltip)
                {
                    if ((this.m_HoverEvent >= 0) && (this.m_HoverEvent < hitPositions.Length))
                    {
                        this.m_InstantTooltipText = AnimationEventPopup.FormatEvent(animatedObject, animationEvents[this.m_HoverEvent]);
                        this.m_InstantTooltipPoint = new Vector2(((hitPositions[this.m_HoverEvent].xMin + ((int) (hitPositions[this.m_HoverEvent].width / 2f))) + rect.x) - 30f, rect.yMax);
                    }
                    this.m_DirtyTooltip = false;
                }
                if ((this.m_EventsSelected == null) || (this.m_EventsSelected.Length != animationEvents.Length))
                {
                    this.m_EventsSelected = new bool[animationEvents.Length];
                    AnimationEventPopup.ClosePopup();
                }
                Vector2 zero = Vector2.zero;
                switch (EditorGUIExt.MultiSelection(rect, positions, new GUIContent(image), hitPositions, ref this.m_EventsSelected, null, out num10, out zero, out num11, out num12, GUIStyleX.none))
                {
                    case HighLevelEvent.ContextClick:
                    {
                        GenericMenu menu = new GenericMenu();
                        menu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new EventLineContextMenuObject(animatedObject, clip, animationEvents[num10].time));
                        menu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), num10);
                        menu.ShowAsContext();
                        this.m_InstantTooltipText = null;
                        this.m_DirtyTooltip = true;
                        base.Repaint();
                        break;
                    }
                    case HighLevelEvent.BeginDrag:
                        m_EventsAtMouseDown = animationEvents;
                        m_EventTimes = new float[animationEvents.Length];
                        for (int k = 0; k < animationEvents.Length; k++)
                        {
                            m_EventTimes[k] = animationEvents[k].time;
                        }
                        break;

                    case HighLevelEvent.Drag:
                    {
                        for (int m = animationEvents.Length - 1; m >= 0; m--)
                        {
                            if (this.m_EventsSelected[m])
                            {
                                AnimationEvent event4 = m_EventsAtMouseDown[m];
                                event4.time = m_EventTimes[m] + (zero.x * this.PixelDeltaToTime(rect));
                                event4.time = Mathf.Max(0f, event4.time);
                                event4.time = ((float) Mathf.RoundToInt(event4.time * clip.frameRate)) / clip.frameRate;
                            }
                        }
                        int[] items = new int[this.m_EventsSelected.Length];
                        for (int n = 0; n < items.Length; n++)
                        {
                            items[n] = n;
                        }
                        Array.Sort(m_EventsAtMouseDown, items, new EventComparer());
                        bool[] flagArray = (bool[]) this.m_EventsSelected.Clone();
                        float[] numArray2 = (float[]) m_EventTimes.Clone();
                        for (int num16 = 0; num16 < items.Length; num16++)
                        {
                            this.m_EventsSelected[num16] = flagArray[items[num16]];
                            m_EventTimes[num16] = numArray2[items[num16]];
                        }
                        Undo.RegisterUndo(clip, "Move Event");
                        AnimationUtility.SetAnimationEvents(clip, m_EventsAtMouseDown);
                        this.m_DirtyTooltip = true;
                        this.SetDirtyProperties();
                        break;
                    }
                    case HighLevelEvent.Delete:
                        this.DeleteEvents(clip, this.m_EventsSelected);
                        break;

                    case HighLevelEvent.SelectionChanged:
                        this.m_CurveEditor.SelectNone();
                        if (num10 >= 0)
                        {
                            AnimationEventPopup.Edit(animatedObject, clip, num10);
                        }
                        break;
                }
            }
            if (((Event.current.type == EventType.ContextClick) && rect2.Contains(Event.current.mousePosition)) && selection.EnsureClipPresence())
            {
                Event.current.Use();
                float num17 = ((float) Mathf.RoundToInt(this.PixelToTime(Event.current.mousePosition.x, rect) * this.m_FrameRate)) / this.m_FrameRate;
                GenericMenu menu2 = new GenericMenu();
                menu2.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new EventLineContextMenuObject(animatedObject, clip, num17));
                menu2.ShowAsContext();
            }
            GUI.color = color;
            GUI.EndGroup();
            GUI.enabled = true;
        }

        private string FormatFrame(int frame)
        {
            int frameRate = (int) this.m_FrameRate;
            return this.FormatFrame(frame, frameRate.ToString().Length);
        }

        private string FormatFrame(int frame, int frameDigits)
        {
            int num = frame / ((int) this.m_FrameRate);
            float num2 = ((float) frame) % this.m_FrameRate;
            return (num.ToString() + ":" + num2.ToString().PadLeft(frameDigits, '0'));
        }

        private float FrameDeltaToPixel(Rect rect)
        {
            return (rect.width / this.frameSpan);
        }

        public void FrameSelected()
        {
            this.m_PerformFrameSelected = true;
        }

        private float FrameToPixel(float i, Rect rect)
        {
            return (((i - this.minFrame) * rect.width) / this.frameSpan);
        }

        private float FrameToTime(float frame)
        {
            return (frame / this.m_FrameRate);
        }

        private float FrameToTimeCeiling(float frame)
        {
            return ((frame + 0.5f) / this.m_FrameRate);
        }

        private float FrameToTimeFloor(float frame)
        {
            return ((frame - 0.5f) / this.m_FrameRate);
        }

        private void GenerateAnimationSelections()
        {
            bool flag = AnimationUtility.InAnimationMode();
            bool flag2 = false;
            int frame = this.m_Frame;
            this.EndAnimationMode();
            List<AnimationSelection> animSelected = new List<AnimationSelection>();
            GameObject activeGameObject = Selection.activeGameObject;
            Transform tr = (activeGameObject == null) ? null : activeGameObject.transform;
            if (tr != null)
            {
                GameObject[] animationComponentsInAllParents = this.GetAnimationComponentsInAllParents(tr);
                if (animationComponentsInAllParents.Length == 0)
                {
                    animationComponentsInAllParents = this.GetAllParents(tr);
                }
                AnimationSelection orAddAnimationSelectionWithObjects = this.GetOrAddAnimationSelectionWithObjects(animationComponentsInAllParents, animSelected);
                foreach (AnimationSelection selection2 in this.m_Selected)
                {
                    if (selection2.animatedObject == orAddAnimationSelectionWithObjects.animatedObject)
                    {
                        flag2 = true;
                    }
                }
                FoldoutTree tree = new FoldoutTree(tr, this.m_ExpandedFoldouts);
                orAddAnimationSelectionWithObjects.AddTree(tree);
            }
            this.m_Selected = animSelected.ToArray();
            if (flag && flag2)
            {
                this.m_Frame = frame;
                this.BeginAnimationMode(false);
            }
            if (!flag2)
            {
                AnimationEventPopup.ClosePopup();
                this.m_EventsSelected = null;
            }
            Unsupported.SceneTrackerFlushDirty();
            if (this.m_GameObjectAndHierarchyChangeTracker == null)
            {
                this.m_GameObjectAndHierarchyChangeTracker = new GameObjectAndHierarchyChangeTracker();
            }
            this.m_GameObjectAndHierarchyChangeTracker.SetTrackedGameObjects(this.GetTrackedGameObjects());
        }

        private GenericMenu GenerateMenu(int[] curveLinked, int[] keyLinked)
        {
            bool flag = true;
            bool flag2 = true;
            foreach (int num in curveLinked)
            {
                if (this.m_ShownProperties[num].animated)
                {
                    flag2 = false;
                }
                else
                {
                    flag = false;
                }
            }
            GenericMenu menu = new GenericMenu();
            string text = (curveLinked.Length <= 1) ? "Add Curve" : "Add Curves";
            if (flag)
            {
                menu.AddDisabledItem(new GUIContent(text));
            }
            else
            {
                menu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.AddCurves), new List<int>(curveLinked));
            }
            text = (curveLinked.Length <= 1) ? "Delete Curve" : "Delete Curves";
            if (flag2)
            {
                menu.AddDisabledItem(new GUIContent(text));
            }
            else
            {
                menu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.DeleteCurves), new List<int>(curveLinked));
            }
            if (!flag2)
            {
                bool flag3 = true;
                bool on = true;
                bool flag5 = true;
                foreach (int num3 in curveLinked)
                {
                    CurveState state = this.m_ShownProperties[num3];
                    if (state.curveData.propertyName.StartsWith("localEulerAngles"))
                    {
                        if (state.curveData.propertyName.StartsWith("localEulerAnglesBaked."))
                        {
                            flag5 = false;
                        }
                        else
                        {
                            on = false;
                        }
                    }
                    else
                    {
                        flag3 = false;
                        break;
                    }
                }
                if (flag3)
                {
                    menu.AddSeparator(string.Empty);
                    text = "Interpolation/Euler Angles";
                    if (flag2)
                    {
                        menu.AddDisabledItem(new GUIContent(text));
                    }
                    else
                    {
                        menu.AddItem(new GUIContent(text), on, new GenericMenu.MenuFunction2(this.UseEulerAnglesInterpolation), new List<int>(curveLinked));
                    }
                    text = "Interpolation/Quaternion";
                    if (flag2)
                    {
                        menu.AddDisabledItem(new GUIContent(text));
                    }
                    else
                    {
                        menu.AddItem(new GUIContent(text), flag5, new GenericMenu.MenuFunction2(this.UseQuaternionInterpolation), new List<int>(curveLinked));
                    }
                }
            }
            if (AnimationUtility.InAnimationMode())
            {
                menu.AddSeparator(string.Empty);
                List<KeyIdentifier> keyList = new List<KeyIdentifier>();
                bool flag6 = true;
                foreach (int num5 in keyLinked)
                {
                    CurveState state2 = this.m_ShownProperties[num5];
                    if (!state2.animated)
                    {
                        flag6 = false;
                        continue;
                    }
                    CurveRenderer curveRenderer = CurveUtility.GetCurveRenderer(state2.clip, state2.curveData);
                    AnimationCurve curve = curveRenderer.GetCurve();
                    bool flag7 = false;
                    for (int i = 0; i < curve.length; i++)
                    {
                        Keyframe keyframe = curve[i];
                        if (keyframe.time >= this.timeFloor)
                        {
                            Keyframe keyframe2 = curve[i];
                            if (keyframe2.time >= this.timeCeiling)
                            {
                                break;
                            }
                            keyList.Add(new KeyIdentifier(curveRenderer, state2.GetID(), i));
                            flag7 = true;
                        }
                    }
                    if (!flag7)
                    {
                        flag6 = false;
                    }
                }
                bool flag8 = keyList.Count == 0;
                text = "Add Key";
                if (flag6)
                {
                    menu.AddDisabledItem(new GUIContent(text));
                }
                else
                {
                    menu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.AddKeysAtTime), new List<int>(keyLinked));
                }
                text = "Delete Key";
                if (flag8)
                {
                    menu.AddDisabledItem(new GUIContent(text));
                }
                else
                {
                    menu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(this.DeleteKeysAtTime), new List<int>(keyLinked));
                }
                if (!flag8)
                {
                    menu.AddSeparator(string.Empty);
                    this.m_MenuManager = new CurveMenuManager(this);
                    this.m_MenuManager.AddTangentMenuItems(menu, keyList);
                }
            }
            return menu;
        }

        private int[] GetAffectedProperties(int clicked, bool onlyLinkEuler)
        {
            if (this.m_SelectedProperties[clicked])
            {
                List<int> list = new List<int>();
                for (int i = 0; i < this.m_ShownProperties.Length; i++)
                {
                    if (this.m_SelectedProperties[i])
                    {
                        list.Add(i);
                    }
                }
                return this.GetLinkedProperties(list.ToArray(), onlyLinkEuler);
            }
            int[] indices = new int[] { clicked };
            return this.GetLinkedProperties(indices, onlyLinkEuler);
        }

        private GameObject[] GetAllParents(Transform tr)
        {
            List<GameObject> list = new List<GameObject> {
                tr.gameObject
            };
            while (tr != tr.root)
            {
                tr = tr.parent;
                list.Add(tr.gameObject);
            }
            list.Reverse();
            return list.ToArray();
        }

        private GameObject[] GetAnimationComponentsInAllParents(Transform tr)
        {
            List<GameObject> list = new List<GameObject>();
            while (true)
            {
                if (tr.animation != null)
                {
                    list.Add(tr.gameObject);
                }
                if (tr == tr.root)
                {
                    break;
                }
                tr = tr.parent;
            }
            list.Reverse();
            return list.ToArray();
        }

        public bool GetAutoRecordMode()
        {
            return this.m_AutoRecord;
        }

        private List<CurveState> GetCurveStates(int[] indices)
        {
            List<CurveState> list = new List<CurveState>();
            for (int i = 0; i < indices.Length; i++)
            {
                list.Add(this.m_ShownProperties[indices[i]]);
            }
            return list;
        }

        internal Rect GetFieldRect(float width)
        {
            return new Rect(((width - 22f) - 45f) - 5f, (float) vPosition, 45f, 12f);
        }

        internal Rect GetIconButtonRect(float width)
        {
            return new Rect(width - 22f, (float) vPosition, 22f, 12f);
        }

        internal Rect GetIconRect(float width)
        {
            return new Rect((width - 22f) + 2f, (float) vPosition, 11f, 12f);
        }

        private int[] GetLinkedProperties(int[] indices, bool onlyLinkEuler)
        {
            List<int> list = new List<int>();
            if (indices.Length != 0)
            {
                int index = 0;
                for (int i = 0; i < this.m_ShownProperties.Length; i++)
                {
                    int j = i;
                    bool flag = false;
                    while ((j < this.m_ShownProperties.Length) && ((i == j) || this.AreLinked(i, j, onlyLinkEuler)))
                    {
                        if (j == indices[index])
                        {
                            flag = true;
                            if (index < (indices.Length - 1))
                            {
                                index++;
                            }
                        }
                        j++;
                    }
                    if (flag)
                    {
                        for (int k = i; k < j; k++)
                        {
                            list.Add(k);
                        }
                        i = j - 1;
                    }
                }
            }
            return list.ToArray();
        }

        internal Rect GetObjectLabelRect(float width)
        {
            int num = 2 + (EditorGUI.indentLevel * 6);
            return new Rect((float) num, (float) vPosition, (((width - num) - 22f) - 45f) - 15f, 15f);
        }

        internal Rect GetObjectLabelRect2(float width)
        {
            int num = 14 + (EditorGUI.indentLevel * 15);
            return new Rect((float) num, (float) vPosition, (((width - num) - 22f) - 45f) - 15f, 15f);
        }

        private AnimationSelection GetOrAddAnimationSelectionWithObjects(GameObject[] animatedOptions, List<AnimationSelection> animSelected)
        {
            AnimationSelection item = null;
            string objectListHashCode = AnimationSelection.GetObjectListHashCode(animatedOptions);
            foreach (AnimationSelection selection2 in animSelected)
            {
                if (AnimationSelection.GetObjectListHashCode(selection2.animatedOptions) == objectListHashCode)
                {
                    item = selection2;
                    break;
                }
            }
            if (item == null)
            {
                item = new AnimationSelection(animatedOptions, this.m_ChosenAnimated, this.m_ChosenClip, this);
                animSelected.Add(item);
            }
            return item;
        }

        internal Rect GetPropertyLabelRect(float width)
        {
            return this.GetPropertyLabelRect(width, (float) (0x1b + (EditorGUI.indentLevel * 15)));
        }

        internal Rect GetPropertyLabelRect(float width, float pixelIndent)
        {
            return new Rect(pixelIndent, (float) (vPosition - 3), (((width - pixelIndent) - 22f) - 45f) - 15f, 14f);
        }

        internal Vector2 GetPropertyPos(float width)
        {
            return new Vector2((float) (0x1b + (EditorGUI.indentLevel * 15)), (float) vPosition);
        }

        internal Rect GetPropertySelectionRect(float width)
        {
            return new Rect(0f, (float) vPosition, ((width - 22f) - 45f) - 15f, 12f);
        }

        private string GetPropertySummary(List<CurveState> states)
        {
            if (states.Count == 0)
            {
                return "None";
            }
            if (states.Count == 1)
            {
                return CurveUtility.GetPropertyName(states[0].curveData.propertyName);
            }
            if (states.Count == 3)
            {
                bool flag = true;
                string propertyName = states[0].curveData.propertyName;
                propertyName = propertyName.Substring(0, propertyName.Length - 2);
                for (int i = 1; i < states.Count; i++)
                {
                    if (!states[i].curveData.propertyName.StartsWith(propertyName))
                    {
                        flag = false;
                    }
                }
                if (flag)
                {
                    return CurveUtility.GetPropertyName(propertyName);
                }
            }
            return "Selected Properties";
        }

        private int[] GetShownOrSelectedProperties()
        {
            int[] trueIndices = this.GetTrueIndices(this.m_SelectedProperties);
            if (trueIndices.Length > 0)
            {
                return trueIndices;
            }
            return this.m_EditedCurves;
        }

        private float GetTimeSeconds()
        {
            if (this.m_PlayMode)
            {
                return this.m_PlayTime;
            }
            return this.FrameToTime((float) this.m_Frame);
        }

        private GameObject[] GetTrackedGameObjects()
        {
            List<GameObject> list = new List<GameObject>();
            if (this.m_Selected.Length > 0)
            {
                FoldoutTree tree = this.m_Selected[0].trees[0];
                for (int i = 0; i < tree.states.Length; i++)
                {
                    GameObject item = tree.states[i].obj;
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return list.ToArray();
        }

        private int[] GetTrueIndices(bool[] array)
        {
            List<int> list = new List<int>();
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i])
                {
                    list.Add(i);
                }
            }
            return list.ToArray();
        }

        private void HandlePropertySelectionsOnPropertyListChange(List<CurveState> oldProps, List<CurveState> newProps, bool makeNewSelected)
        {
            bool[] flagArray = new bool[newProps.Count];
            bool flag = true;
            for (int i = 0; i < this.m_SelectedProperties.Length; i++)
            {
                if (this.m_SelectedProperties[i])
                {
                    flag = false;
                    break;
                }
            }
            if (flag)
            {
                this.m_SelectedProperties = flagArray;
            }
            else
            {
                if (makeNewSelected)
                {
                    for (int k = 0; k < flagArray.Length; k++)
                    {
                        flagArray[k] = true;
                    }
                }
                for (int j = 0; j < this.m_SelectedProperties.Length; j++)
                {
                    if (this.m_SelectedProperties[j] != makeNewSelected)
                    {
                        int iD = oldProps[j].GetID();
                        for (int m = 0; m < newProps.Count; m++)
                        {
                            if (newProps[m].GetID() == iD)
                            {
                                flagArray[m] = !makeNewSelected;
                                break;
                            }
                        }
                    }
                }
                this.m_SelectedProperties = flagArray;
            }
        }

        private void InitSelection()
        {
            this.ClearShownProperties();
            this.GenerateAnimationSelections();
            this.Refresh();
        }

        private bool IsLinked(CurveState state, bool onlyLinkEuler)
        {
            if (state.curveData.type != typeof(Transform))
            {
                return false;
            }
            if (onlyLinkEuler && !state.curveData.propertyName.StartsWith("localEulerAngles."))
            {
                return false;
            }
            return true;
        }

        public void KeyframeLineContextMenuAdd(object obj)
        {
            int frame = (int) obj;
            this.RecordKeyframe(this.GetShownOrSelectedProperties(), frame, true);
            this.PreviewFrame(frame);
        }

        public void KeyframeLineContextMenuDelete(object obj)
        {
            int index = (int) obj;
            if (this.m_KeyframesSelected[index])
            {
                this.DeleteKeyframes(this.m_KeyframesSelected);
            }
            else
            {
                bool[] deleteIndices = new bool[this.m_KeyframesSelected.Length];
                deleteIndices[index] = true;
                this.DeleteKeyframes(deleteIndices);
            }
        }

        private void KeyframesGUI(Rect rect)
        {
            if (this.m_Selected.Length != 0)
            {
                Vector2 vector;
                int num9;
                float num10;
                float num11;
                Color backgroundColor = GUI.backgroundColor;
                GUI.BeginGroup(rect);
                Rect rect2 = new Rect(0f, 0f, rect.width, rect.height);
                if (((Event.current.type == EventType.MouseUp) && (Event.current.clickCount == 2)) && rect2.Contains(Event.current.mousePosition))
                {
                    Event.current.Use();
                    int frame = Mathf.RoundToInt(this.PixelToTime(Event.current.mousePosition.x, rect) * this.m_FrameRate);
                    this.RecordKeyframe(this.GetShownOrSelectedProperties(), frame, true);
                    this.PreviewFrame(frame);
                }
                int width = ms_Styles.pointIcon.width;
                int height = ms_Styles.pointIcon.height;
                int num4 = 0;
                int num5 = 0;
                int num6 = 0;
                Rect[] hitPositions = new Rect[this.m_Keyframes.Length];
                Rect[] positions = new Rect[this.m_Keyframes.Length];
                if (this.m_Keyframes.Length >= 2)
                {
                    num4 = Mathf.FloorToInt(this.FrameToPixel((float) this.m_Keyframes[1], rect));
                }
                if (this.m_Keyframes.Length >= 1)
                {
                    num5 = Mathf.FloorToInt(this.FrameToPixel((float) this.m_Keyframes[0], rect));
                }
                for (int i = 0; i < this.m_Keyframes.Length; i++)
                {
                    positions[i] = new Rect((float) (num5 - (width / 2)), (float) (7 - (width / 2)), (float) width, (float) height);
                    hitPositions[i] = positions[i];
                    if (i > 0)
                    {
                        hitPositions[i].xMin = Mathf.Max(hitPositions[i].xMin, (num6 + num5) * 0.5f);
                    }
                    if (i < (this.m_Keyframes.Length - 1))
                    {
                        num4 = Mathf.FloorToInt(this.FrameToPixel((float) this.m_Keyframes[i + 1], rect));
                        hitPositions[i].xMax = Mathf.Min(hitPositions[i].xMax, (num4 + num5) * 0.5f);
                    }
                    num6 = num5;
                    num5 = num4;
                }
                this.m_KeyframeRects = new Rect[hitPositions.Length];
                for (int j = 0; j < hitPositions.Length; j++)
                {
                    this.m_KeyframeRects[j] = new Rect(hitPositions[j].x + rect.x, hitPositions[j].y + rect.y, hitPositions[j].width, hitPositions[j].height);
                }
                HighLevelEvent event2 = EditorGUIExt.MultiSelection(rect, positions, new GUIContent(ms_Styles.pointIcon), hitPositions, ref this.m_KeyframesSelected, this.m_KeyframesReadOnly, out num9, out vector, out num10, out num11, GUIStyleX.none);
                Undo.SetSnapshotTarget(this.m_CurveEditor.m_UndoObjects, "Move Keyframes");
                switch (event2)
                {
                    case HighLevelEvent.ContextClick:
                    {
                        GenericMenu menu = new GenericMenu();
                        menu.AddItem(new GUIContent("Add Keyframe"), false, new GenericMenu.MenuFunction2(this.KeyframeLineContextMenuAdd), this.m_Keyframes[num9]);
                        menu.AddItem(new GUIContent("Delete Keyframe"), false, new GenericMenu.MenuFunction2(this.KeyframeLineContextMenuDelete), num9);
                        menu.ShowAsContext();
                        break;
                    }
                    case HighLevelEvent.BeginDrag:
                    case HighLevelEvent.Drag:
                    {
                        if (event2 == HighLevelEvent.BeginDrag)
                        {
                            Undo.CreateSnapshot();
                            this.m_CurveEditor.MakeCurveBackups();
                        }
                        float x = this.SnapTimeToWholeFPS(vector.x * this.PixelDeltaToTime(rect));
                        this.m_CurveEditor.UpdateCurvesFromPoints(new Vector2(x, 0f));
                        this.UpdateFrame(s_StartDragFrame + Mathf.RoundToInt(x * this.m_FrameRate));
                        this.m_ActuallyMoved = event2 == HighLevelEvent.Drag;
                        break;
                    }
                    case HighLevelEvent.EndDrag:
                        this.m_CurveEditor.ClearDisplayedSelection();
                        if (this.m_ActuallyMoved)
                        {
                            this.m_ActuallyMoved = false;
                            Undo.RegisterSnapshot();
                        }
                        break;

                    case HighLevelEvent.Delete:
                        this.DeleteKeyframes(this.m_KeyframesSelected);
                        break;

                    case HighLevelEvent.SelectionChanged:
                    {
                        bool flag = true;
                        for (int k = 0; k < this.m_KeyframesSelected.Length; k++)
                        {
                            if (this.m_KeyframesSelected[k])
                            {
                                this.m_CurveEditor.BeginTimeRangeSelection(this.FrameToTimeFloor((float) this.m_Keyframes[k]), !flag);
                                this.m_CurveEditor.TimeRangeSelectTo(this.FrameToTimeCeiling((float) this.m_Keyframes[k]));
                                this.m_CurveEditor.EndTimeRangeSelection();
                                flag = false;
                            }
                        }
                        if (flag)
                        {
                            this.m_CurveEditor.SelectNone();
                        }
                        if (num9 >= 0)
                        {
                            this.UpdateFrame(this.m_Keyframes[num9]);
                            s_StartDragFrame = this.m_Keyframes[num9];
                        }
                        break;
                    }
                }
                if ((Event.current.type == EventType.ContextClick) && rect2.Contains(Event.current.mousePosition))
                {
                    Event.current.Use();
                    int userData = Mathf.RoundToInt(this.PixelToTime(Event.current.mousePosition.x, rect) * this.m_FrameRate);
                    GenericMenu menu2 = new GenericMenu();
                    menu2.AddItem(new GUIContent("Add Keyframe"), false, new GenericMenu.MenuFunction2(this.KeyframeLineContextMenuAdd), userData);
                    menu2.ShowAsContext();
                }
                GUI.EndGroup();
                GUI.backgroundColor = backgroundColor;
                GUIUtility.GetControlID(0x392775, FocusType.Passive);
            }
        }

        private void Next()
        {
            if (this.m_Keyframes.Length != 0)
            {
                int frame = 0x98967f;
                bool flag = false;
                foreach (int num2 in this.m_Keyframes)
                {
                    if ((num2 < frame) && (num2 > this.m_Frame))
                    {
                        frame = num2;
                        flag = true;
                    }
                }
                if (flag)
                {
                    this.PreviewFrame(frame);
                }
            }
        }

        public void OnAnimationClipAwake(AnimationClip clip)
        {
            if (this.m_Selected != null)
            {
                this.SetDirtyProperties();
                base.Repaint();
            }
        }

        public void OnDestroy()
        {
            this.EndAnimationMode();
            AnimationEventPopup.ClosePopup();
            CurveUtility.ClearCurveRendererCache();
        }

        public void OnDisable()
        {
            this.m_GameObjectAndHierarchyChangeTracker.Dispose();
            EditorApplication.onAnimationClipAwake = (EditorApplication.AnimationClipAwake) Delegate.Remove(EditorApplication.onAnimationClipAwake, new EditorApplication.AnimationClipAwake(this.OnAnimationClipAwake));
            EditorApplication.undoRedoPerformed = (EditorApplication.CallbackFunction) Delegate.Remove(EditorApplication.undoRedoPerformed, new EditorApplication.CallbackFunction(this.UndoRedoPerformed));
            this.m_CurveEditor.OnDisable();
        }

        public void OnEnable()
        {
            if (this.m_Selected != null)
            {
                if (this.m_CurveEditor != null)
                {
                    this.m_CurveEditor.m_TimeUpdater = this;
                    this.SetGridColors();
                    this.m_CurveEditor.OnEnable();
                }
                this.SetDirtyProperties();
                if (this.m_GameObjectAndHierarchyChangeTracker == null)
                {
                    this.m_GameObjectAndHierarchyChangeTracker = new GameObjectAndHierarchyChangeTracker();
                }
                this.m_GameObjectAndHierarchyChangeTracker.SetTrackedGameObjects(this.GetTrackedGameObjects());
            }
        }

        public void OnGUI()
        {
            if (((this.m_Selected.Length == 0) && (Selection.activeGameObject != null)) || ((this.m_Selected.Length > 0) && (this.m_Selected[0].ShownRoot() != Selection.activeGameObject)))
            {
                this.OnSelectionChange();
            }
            if (this.m_Selected.Length == 0)
            {
                this.EndAnimationMode();
            }
            int width = this.m_Splitter.realSizes[0];
            vPosition = 0;
            int num2 = 15;
            float num3 = base.position.width - width;
            Rect rect = new Rect((float) width, (float) vPosition, num3 - num2, 17f);
            vPosition += 0x11;
            Rect eventLineRect = new Rect((float) width, (float) vPosition, num3 - num2, 15f);
            vPosition += (int) eventLineRect.height;
            Rect keyframeLineRect = new Rect((float) width, (float) vPosition, num3 - num2, 15f);
            vPosition += 15;
            Rect position = new Rect((float) width, 0f, num3 - num2, keyframeLineRect.yMax);
            Rect rect5 = new Rect((float) width, (float) vPosition, num3, base.position.height - vPosition);
            vPosition = Mathf.RoundToInt(base.position.height) - num2;
            if (Event.current.type == EventType.MouseMove)
            {
                this.CheckRectsOnMouseMove(eventLineRect, keyframeLineRect);
                if (this.m_DirtyTooltip)
                {
                    base.Repaint();
                }
            }
            else
            {
                if (this.m_DirtyTooltip)
                {
                    this.CheckRectsOnMouseMove(eventLineRect, keyframeLineRect);
                }
                if (ms_Styles == null)
                {
                    ms_Styles = new Styles();
                }
                Handles.lighting = false;
                if (!AnimationUtility.InAnimationMode())
                {
                    this.m_AutoRecord = false;
                    this.m_Frame = 0;
                }
                GUI.changed = false;
                vPosition = 0;
                kEvenRow = true;
                bool enabled = GUI.enabled;
                SplitterGUILayout.BeginHorizontalSplit(this.m_Splitter, new GUILayoutOption[0]);
                GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MaxWidth((float) width) };
                EditorGUILayout.BeginVertical(options);
                GUI.changed = false;
                GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width((float) width) };
                EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, optionArray2);
                GUI.enabled = (this.m_Selected.Length > 0) && this.m_Selected[0].GameObjectIsAnimatable;
                if (this.m_PlayFromNoMode)
                {
                    if (GUILayout.Toggle(false, ms_Styles.recordContent, EditorStyles.toolbarButton, new GUILayoutOption[0]))
                    {
                        this.Stop();
                        this.ToggleAnimationMode();
                    }
                }
                else
                {
                    Color color = GUI.color;
                    if (AnimationUtility.InAnimationMode())
                    {
                        GUI.color = color * new Color(1f, 0.5f, 0.5f, 1f);
                    }
                    bool flag3 = GUILayout.Toggle(AnimationUtility.InAnimationMode(), ms_Styles.recordContent, EditorStyles.toolbarButton, new GUILayoutOption[0]);
                    GUI.color = color;
                    if (flag3 != AnimationUtility.InAnimationMode())
                    {
                        this.ToggleAnimationMode();
                    }
                    GUI.color = color;
                }
                this.SetPlayMode(GUILayout.Toggle(this.m_PlayMode, ms_Styles.playContent, EditorStyles.toolbarButton, new GUILayoutOption[0]));
                EditorGUILayout.Space();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(ms_Styles.prevKeyContent, EditorStyles.toolbarButton, new GUILayoutOption[0]))
                {
                    this.Prev();
                }
                if (GUILayout.Button(ms_Styles.nextKeyContent, EditorStyles.toolbarButton, new GUILayoutOption[0]))
                {
                    this.Next();
                }
                EditorGUILayout.Space();
                GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.Width(35f) };
                int b = EditorGUILayout.IntField(this.m_Frame, EditorStyles.toolbarTextField, optionArray3);
                b = Mathf.Max(0, b);
                if (b != this.m_Frame)
                {
                    this.PreviewFrame(b);
                }
                EditorGUILayout.Space();
                GUI.enabled = (AnimationUtility.InAnimationMode() && (this.m_Selected.Length > 0)) && this.m_Selected[0].CanClipAndGameObjectBeEdited;
                if (GUILayout.Button(ms_Styles.addKeyframeContent, EditorStyles.toolbarButton, new GUILayoutOption[0]))
                {
                    this.RecordKeyframe(this.GetShownOrSelectedProperties(), this.m_Frame, true);
                    this.PreviewFrame(this.m_Frame);
                }
                if (GUILayout.Button(ms_Styles.addEventContent, EditorStyles.toolbarButton, new GUILayoutOption[0]) && (this.m_Selected.Length > 0))
                {
                    AnimationSelection selection = this.m_Selected[0];
                    if (selection.EnsureClipPresence())
                    {
                        float time = ((float) this.m_Frame) / this.m_FrameRate;
                        AnimationEventPopup.Create(selection.animatedObject, selection.clip, time);
                        this.SetDirtyProperties();
                    }
                }
                GUI.enabled = enabled;
                if (this.maxFrame < (this.minFrame + 5f))
                {
                    this.m_CurveEditor.SetShownHRange(this.minTime, this.minTime + (5f / this.m_FrameRate));
                }
                EditorGUILayout.EndHorizontal();
                GUI.changed = false;
                if (GUI.Button(new Rect(0f, base.position.height - 15f, (float) (width / 2), 15f), !this.m_ShowAllProperties ? "Show: Animated" : "Show: All", ms_Styles.miniToolbarButton))
                {
                    this.m_ShowAllProperties = !this.m_ShowAllProperties;
                    this.SetDirtyPropertyList();
                }
                Rect rect6 = new Rect((float) (width / 2), base.position.height - 15f, (float) (width / 2), 15f);
                if ((this.m_Selected.Length > 0) && (this.m_Selected[0].clip != null))
                {
                    GUI.enabled = this.m_Selected[0].CanClipAndGameObjectBeEdited;
                    WrapMode mode = (WrapMode) EditorGUI.EnumPopup(rect6, (WrapModeFixed) this.m_Selected[0].clip.wrapMode, ms_Styles.miniToolbarPopup);
                    if (mode != this.m_Selected[0].clip.wrapMode)
                    {
                        this.m_Selected[0].clip.wrapMode = mode;
                        this.SetDirtyCurves();
                    }
                    GUI.enabled = enabled;
                }
                else
                {
                    EditorGUI.Popup(rect6, 0, new GUIContent[0], ms_Styles.miniToolbarPopup);
                }
                GUI.changed = false;
                if (this.m_Selected.Length > 0)
                {
                    AnimationSelection.OnGUISelection(this.m_Selected[0], width);
                }
                else
                {
                    AnimationSelection.OnGUISelection(null, width);
                }
                GUILayoutUtility.GetRect((float) width, 15f);
                List<CurveState> shownProperties = new List<CurveState>();
                GUILayoutOption[] optionArray4 = new GUILayoutOption[] { GUILayout.Width((float) width) };
                this.m_PropertyViewScroll = EditorGUILayout.BeginScrollView(this.m_PropertyViewScroll, optionArray4);
                GUILayoutOption[] optionArray5 = new GUILayoutOption[] { GUILayout.ExpandWidth(true) };
                int num6 = (int) GUILayoutUtility.GetRect((float) 1f, (float) 0f, optionArray5).width;
                if (this.m_DirtyProperties)
                {
                    this.RefreshAnimationSelections();
                }
                EditorGUIUtility.SetIconSize(new Vector2(12f, 12f));
                if (this.m_Selected.Length > 0)
                {
                    this.m_Selected[0].OnGUIHierarchy(shownProperties);
                }
                GUILayoutOption[] optionArray6 = new GUILayoutOption[] { GUILayout.ExpandWidth(true) };
                GUILayoutUtility.GetRect((float) 50f, (float) vPosition, optionArray6);
                if (this.m_DirtyPropertyList || !this.AreSameProperties(this.m_ShownProperties, shownProperties.ToArray()))
                {
                    if (this.m_ShownProperties.Length != this.m_SelectedProperties.Length)
                    {
                        Debug.LogError("m_ShownProperties.Length != m_SelectedProperties.Length");
                    }
                    this.HandlePropertySelectionsOnPropertyListChange(new List<CurveState>(this.m_ShownProperties), shownProperties, true);
                    this.m_DirtyPropertyList = false;
                }
                this.m_ShownProperties = shownProperties.ToArray();
                if (this.m_DirtyProperties)
                {
                    this.m_DirtyProperties = false;
                    CurveUtility.ClearCurveRendererCache();
                }
                this.SelectionControlGUI(num6);
                this.CalculateEditedCurves();
                EditorGUIUtility.SetIconSize(Vector2.zero);
                GUILayout.EndScrollView();
                if (Event.current.type == EventType.Repaint)
                {
                    float x = GUILayoutUtility.GetLastRect().x;
                    float num8 = GUILayoutUtility.GetLastRect().y - this.m_PropertyViewScroll.y;
                    for (int i = 0; i < this.m_PropertyIconRects.Length; i++)
                    {
                        this.m_PropertyIconRects[i].x += x;
                        this.m_PropertyIconRects[i].y += num8;
                        this.m_PropertyFieldRects[i].x += x;
                        this.m_PropertyFieldRects[i].y += num8;
                    }
                }
                GUILayoutUtility.GetRect((float) 10f, (float) 16f);
                if (GUI.changed || this.m_DirtyCurves)
                {
                    this.RefreshShownCurves();
                }
                EditorGUILayout.EndVertical();
                GUIUtility.GetControlID(0x3537a5, FocusType.Passive);
                GUI.changed = false;
                GUILayoutOption[] optionArray7 = new GUILayoutOption[] { GUILayout.ExpandWidth(true) };
                EditorGUILayout.BeginVertical(optionArray7);
                EditorGUILayout.BeginHorizontal("Toolbar", new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
                GUI.Label(eventLineRect, GUIContent.none, ms_Styles.eventBackground);
                GUI.Label(keyframeLineRect, GUIContent.none, ms_Styles.keyframeBackground);
                GUI.Label(this.m_CurveEditor.drawRect, GUIContent.none, ms_Styles.curveEditorBackground);
                this.m_CurveEditor.rect = rect5;
                this.m_CurveEditor.hRangeLocked = Event.current.shift;
                this.m_CurveEditor.vRangeLocked = EditorGUI.actionKey;
                if (this.m_PerformFrameSelected)
                {
                    this.m_CurveEditor.FrameSelected(false, true);
                    this.m_PerformFrameSelected = false;
                }
                GUI.changed = false;
                this.m_CurveEditor.BeginViewGUI();
                this.m_CurveEditor.GridGUI();
                GUI.BeginGroup(this.m_CurveEditor.drawRect);
                if (AnimationUtility.InAnimationMode())
                {
                    float num10 = this.TimeToPixel(this.GetTimeSeconds(), this.m_CurveEditor.drawRect);
                    Handles.color = new Color(1f, 0f, 0f, 0.25f);
                    Handles.DrawLine(new Vector3(num10, 0f), new Vector3(num10, this.m_CurveEditor.drawRect.height));
                    Handles.DrawLine(new Vector3(num10 + 1f, 0f), new Vector3(num10 + 1f, this.m_CurveEditor.drawRect.height));
                }
                this.m_CurveEditor.hRangeMin = 0f;
                GUI.EndGroup();
                this.m_CurveEditor.CurveGUI();
                this.m_CurveEditor.EndViewGUI();
                this.m_TimeLineArea.rect = position;
                this.m_TimeLineArea.SetShownHRange(this.minTime, this.maxTime);
                this.SecondaryTickMarksGUI(new Rect(position.x, 17f, position.width, 30f));
                this.TimeLineGUI(rect);
                GUI.BeginGroup(position);
                if ((AnimationUtility.InAnimationMode() && (this.m_Frame >= (this.minFrame - 1f))) && (this.m_Frame < this.maxFrame))
                {
                    float num11 = this.TimeToPixel(this.GetTimeSeconds(), position);
                    Handles.color = new Color(1f, 0f, 0f);
                    Handles.DrawLine((Vector3) new Vector2(num11, 0f), (Vector3) new Vector2(num11, position.height));
                    Handles.DrawLine((Vector3) new Vector2(num11 + 1f, 0f), (Vector3) new Vector2(num11 + 1f, position.height));
                }
                GUI.EndGroup();
                if (this.m_Selected.Length > 0)
                {
                    this.EventLineGUI(eventLineRect, this.m_Selected[0]);
                }
                this.KeyframesGUI(keyframeLineRect);
                this.m_TimeLineArea.BeginViewGUI();
                Rect shownArea = this.m_TimeLineArea.shownArea;
                this.m_CurveEditor.SetShownHRange(shownArea.xMin, shownArea.xMax);
                if (this.m_Selected.Length > 0)
                {
                    int num12 = Mathf.RoundToInt(GUI.HorizontalSlider(rect, (float) this.m_Frame, this.minFrame, this.maxFrame, GUIStyle.none, GUIStyle.none));
                    num12 = Mathf.Max(0, num12);
                    if (num12 != this.m_Frame)
                    {
                        this.PreviewFrame(num12);
                    }
                }
                this.m_TimeLineArea.EndViewGUI();
                if (this.m_ShownProperties == null)
                {
                    Debug.LogError("m_ShownProperties is null");
                }
                else if (this.m_CurveEditor.animationCurves.Length != this.m_EditedCurves.Length)
                {
                    Debug.LogError(string.Concat(new object[] { "animationCurves and m_EditedCurves not same length! (", this.m_CurveEditor.animationCurves.Length, " vs ", this.m_EditedCurves.Length, ")" }));
                }
                else
                {
                    int num13 = 0;
                    for (int j = 0; j < this.m_EditedCurves.Length; j++)
                    {
                        if (this.m_CurveEditor.animationCurves[j] == null)
                        {
                            Debug.LogError("Curve " + j + " is null");
                        }
                        CurveState state = this.m_ShownProperties[this.m_EditedCurves[j]];
                        if (this.m_CurveEditor.animationCurves[j].changed)
                        {
                            this.m_CurveEditor.animationCurves[j].changed = false;
                            num13++;
                            if (this.EnsureAnimationMode())
                            {
                                state.SaveCurve(this.m_CurveEditor.animationCurves[j].curve);
                            }
                        }
                    }
                    if (num13 > 0)
                    {
                        this.SetDirtyCurves();
                    }
                }
                EditorGUILayout.EndVertical();
                SplitterGUILayout.EndHorizontalSplit();
                this.AnimationControls();
                Rect rect8 = base.position;
                rect8.x = 0f;
                rect8.y = 0f;
                if ((((Event.current.type == EventType.MouseDown) && rect8.Contains(Event.current.mousePosition)) && ((Event.current.button == 0) && !Event.current.shift)) && !Event.current.control)
                {
                    GUIUtility.keyboardControl = 0;
                    if ((Event.current.mousePosition.x < width) && (Event.current.mousePosition.y > 32f))
                    {
                        for (int k = 0; k < this.m_SelectedProperties.Length; k++)
                        {
                            this.m_SelectedProperties[k] = false;
                        }
                        this.SetDirtyCurves();
                    }
                    Event.current.Use();
                }
                this.DrawInstantTooltip();
            }
        }

        private void OnInspectorUpdate()
        {
            if (!AnimationUtility.InAnimationMode())
            {
                this.m_AutoRecord = false;
            }
            if ((this.m_GameObjectAndHierarchyChangeTracker != null) && this.m_GameObjectAndHierarchyChangeTracker.isDirty)
            {
                this.OnSelectionChange();
            }
            if (this.m_AutoRecord)
            {
                this.TickAutoRecord();
            }
        }

        public void OnSelectionChange()
        {
            this.InitSelection();
            this.FrameSelected();
        }

        private float PixelDeltaToTime(Rect rect)
        {
            return (this.timeSpan / rect.width);
        }

        private float PixelToTime(float pixelX, Rect rect)
        {
            return (((pixelX * this.timeSpan) / rect.width) + this.minTime);
        }

        private void Play()
        {
            bool flag = !AnimationUtility.InAnimationMode();
            if (this.EnsureAnimationMode())
            {
                this.m_PlayFromNoMode = flag;
                this.m_PlayMode = true;
                this.m_PlayTime = Mathf.Max(0f, this.minTime);
                this.m_PrevRealTime = Time.realtimeSinceStartup;
            }
        }

        private void Prev()
        {
            if (this.m_Keyframes.Length != 0)
            {
                int frame = -9999999;
                bool flag = false;
                foreach (int num2 in this.m_Keyframes)
                {
                    if ((num2 > frame) && (num2 < this.m_Frame))
                    {
                        frame = num2;
                        flag = true;
                    }
                }
                if (flag)
                {
                    this.PreviewFrame(frame);
                }
            }
        }

        private void PreviewFrame(int frame)
        {
            if (this.EnsureAnimationMode())
            {
                this.m_Frame = frame;
                this.ResampleAnimation();
                this.m_RemoveTextFieldFocus = true;
            }
        }

        private void RecalculateKeyframes()
        {
            SortedDictionary<int, bool> dictionary = new SortedDictionary<int, bool>();
            bool flag = this.AnyPropertiesSelected();
            bool flag2 = (this.m_Selected.Length == 0) || !this.m_Selected[0].CanClipAndGameObjectBeEdited;
            for (int i = 0; i < this.m_ShownProperties.Length; i++)
            {
                CurveState state = this.m_ShownProperties[i];
                if (state.animated && (!flag || this.m_SelectedProperties[i]))
                {
                    AnimationCurve curve = state.curve;
                    if (curve != null)
                    {
                        for (int j = 0; j < curve.length; j++)
                        {
                            Keyframe keyframe = curve[j];
                            int key = Mathf.RoundToInt(keyframe.time * this.m_FrameRate);
                            if (!dictionary.ContainsKey(key) || dictionary[key])
                            {
                                dictionary[key] = flag2;
                            }
                        }
                    }
                }
            }
            this.m_Keyframes = new int[dictionary.Count];
            this.m_KeyframesReadOnly = new bool[dictionary.Count];
            this.m_KeyframesSelected = new bool[dictionary.Count];
            int index = 0;
            foreach (KeyValuePair<int, bool> pair in dictionary)
            {
                this.m_Keyframes[index] = pair.Key;
                this.m_KeyframesReadOnly[index] = pair.Value;
                index++;
            }
        }

        private void RecordKeyframe(int[] indices, int frame, bool overwriteExisting)
        {
            if (this.EnsureAnimationMode())
            {
                this.AddCurves(this.GetLinkedProperties(indices, false), frame);
                this.DoRecord(indices, frame, overwriteExisting);
                this.SetDirtyProperties();
            }
        }

        public void ReEnterAnimationMode()
        {
            if (AnimationUtility.InAnimationMode())
            {
                int frame = this.m_Frame;
                this.EndAnimationMode();
                this.m_Frame = frame;
                this.BeginAnimationMode(false);
            }
        }

        private void Refresh()
        {
            this.EvaluateFramerate();
            this.SetDirtyPropertyList();
            base.Repaint();
        }

        private void RefreshAnimationSelections()
        {
            foreach (AnimationSelection selection in this.m_Selected)
            {
                selection.Refresh();
            }
        }

        private void RefreshShownCurves()
        {
            this.m_DirtyCurves = false;
            this.EvaluateFramerate();
            this.m_CurveEditor.invSnap = this.m_FrameRate;
            bool flag = this.AnyPropertiesSelected();
            bool flag2 = (this.m_Selected.Length == 0) || !this.m_Selected[0].CanClipAndGameObjectBeEdited;
            CurveWrapper[] wrapperArray = new CurveWrapper[this.m_EditedCurves.Length];
            for (int i = 0; i < wrapperArray.Length; i++)
            {
                CurveState state = this.m_ShownProperties[this.m_EditedCurves[i]];
                wrapperArray[i] = new CurveWrapper();
                wrapperArray[i].id = state.GetID();
                if (this.IsLinked(state, true))
                {
                    wrapperArray[i].groupId = state.GetGroupID();
                }
                else
                {
                    wrapperArray[i].groupId = -1;
                }
                wrapperArray[i].color = state.color;
                wrapperArray[i].hidden = flag && !this.m_SelectedProperties[this.m_EditedCurves[i]];
                wrapperArray[i].readOnly = flag2;
                if (wrapperArray[i].readOnly)
                {
                    wrapperArray[i].color.a = 0.3f;
                }
                wrapperArray[i].renderer = CurveUtility.GetCurveRenderer(state.clip, state.curveData);
                wrapperArray[i].renderer.SetWrap(state.clip.wrapMode);
                wrapperArray[i].renderer.SetCustomRange(0f, state.clip.length);
            }
            this.m_CurveEditor.animationCurves = wrapperArray;
            UnityEngine.Object[] objArray = new UnityEngine.Object[this.m_Selected.Length];
            for (int j = 0; j < this.m_Selected.Length; j++)
            {
                objArray[j] = this.m_Selected[j].clip;
            }
            this.m_CurveEditor.m_UndoObjects = objArray;
            this.RecalculateKeyframes();
            if (AnimationUtility.InAnimationMode())
            {
                this.ResampleAnimation();
            }
        }

        private void ResampleAnimation()
        {
            if (this.EnsureAnimationMode())
            {
                foreach (AnimationSelection selection in this.m_Selected)
                {
                    AnimationClip animation = selection.clip;
                    if (animation != null)
                    {
                        selection.animatedObject.SampleAnimation(animation, this.GetTimeSeconds());
                        if (!this.m_PlayMode)
                        {
                            selection.RefreshAutoRecordState();
                        }
                    }
                }
            }
        }

        private void SecondaryTickMarksGUI(Rect rect)
        {
            GUI.BeginGroup(rect);
            if (Event.current.type != EventType.Repaint)
            {
                GUI.EndGroup();
            }
            else
            {
                this.m_CurveEditor.hTicks.SetTickStrengths((float) this.m_CurveEditor.settings.hTickStyle.distMin, (float) this.m_CurveEditor.settings.hTickStyle.distFull, false);
                HandleUtility.handleWireMaterial.SetPass(0);
                GL.Begin(1);
                for (int i = 0; i < this.m_CurveEditor.hTicks.tickLevels; i++)
                {
                    float strengthOfLevel = this.m_CurveEditor.hTicks.GetStrengthOfLevel(i);
                    GL.Color((this.m_CurveEditor.settings.hTickStyle.color * new Color(1f, 1f, 1f, strengthOfLevel)) * new Color(1f, 1f, 1f, 0.75f));
                    float[] ticksAtLevel = this.m_CurveEditor.hTicks.GetTicksAtLevel(i, true);
                    for (int j = 0; j < ticksAtLevel.Length; j++)
                    {
                        if (ticksAtLevel[j] >= 0f)
                        {
                            int num4 = Mathf.RoundToInt(ticksAtLevel[j] * this.m_FrameRate);
                            GL.Vertex((Vector3) new Vector2(this.FrameToPixel((float) num4, rect), 0f));
                            GL.Vertex((Vector3) new Vector2(this.FrameToPixel((float) num4, rect), rect.height));
                        }
                    }
                }
                GL.End();
                GUI.EndGroup();
            }
        }

        private void SelectionControlGUI(int width)
        {
            if (Event.current.type == EventType.Repaint)
            {
                this.m_PropertyIconRects = new Rect[this.m_ShownProperties.Length];
                this.m_PropertyFieldRects = new Rect[this.m_ShownProperties.Length];
            }
            Rect[] positions = new Rect[this.m_ShownProperties.Length];
            int vPosition = AnimationWindow.vPosition;
            GUI.enabled = (this.m_Selected.Length > 0) && this.m_Selected[0].CanClipAndGameObjectBeEdited;
            for (int i = 0; i < this.m_ShownProperties.Length; i++)
            {
                Texture iconKey;
                CurveState state = this.m_ShownProperties[i];
                AnimationWindow.vPosition = (int) state.guiPosition.y;
                positions[i] = this.GetPropertySelectionRect((float) width);
                string propertyName = CurveUtility.GetPropertyName(state.curveData.propertyName);
                if (state.curveData.type == typeof(Transform))
                {
                    if (propertyName.StartsWith("Local Euler Angles"))
                    {
                        propertyName = "Rotation" + propertyName.Substring(propertyName.Length - 2, 2);
                    }
                    else if (propertyName.StartsWith("Local Position"))
                    {
                        propertyName = "Position" + propertyName.Substring(propertyName.Length - 2, 2);
                    }
                    else if (propertyName.StartsWith("Local Scale"))
                    {
                        propertyName = "Scale" + propertyName.Substring(propertyName.Length - 2, 2);
                    }
                }
                kEvenRow = state.even;
                if (Event.current.type == EventType.Repaint)
                {
                    this.DrawRowBackground(width, 12, this.m_SelectedProperties[i]);
                }
                Rect propertyLabelRect = this.GetPropertyLabelRect((float) width, state.guiPosition.x);
                if (Event.current.type == EventType.Repaint)
                {
                    EditorStyles.miniLabel.Draw(propertyLabelRect, new GUIContent(propertyName), 0, this.m_SelectedProperties[i]);
                }
                Rect iconButtonRect = this.GetIconButtonRect((float) width);
                if (GUI.Button(iconButtonRect, string.Empty, "AnimPropDropdown"))
                {
                    this.ShowButtonDropDown(iconButtonRect, i);
                }
                if ((this.m_Selected.Length > 0) && this.m_Selected[0].CanClipAndGameObjectBeEdited)
                {
                    this.CheckContextClick(positions[i], i);
                }
                if (Event.current.type == EventType.Repaint)
                {
                    this.m_PropertyIconRects[i] = iconButtonRect;
                    this.m_PropertyFieldRects[i] = this.GetFieldRect((float) width);
                }
                Color white = Color.white;
                if (state.animated)
                {
                    white = state.color;
                    bool flag = false;
                    if (AnimationUtility.InAnimationMode() && CurveUtility.HaveKeysInRange(state.curve, this.timeFloor, this.timeCeiling))
                    {
                        flag = true;
                    }
                    if (flag)
                    {
                        iconKey = CurveUtility.GetIconKey();
                    }
                    else
                    {
                        iconKey = CurveUtility.GetIconCurve();
                    }
                }
                else
                {
                    iconKey = CurveUtility.GetIconNone();
                }
                if (Event.current.type == EventType.Repaint)
                {
                    state.animationSelection.DrawRightIcon(iconKey, white, (float) width);
                }
            }
            GUI.enabled = true;
            if (EditorGUIExt.DragSelection(positions, ref this.m_SelectedProperties, GUIStyle.none))
            {
                GUI.changed = true;
            }
            GUI.enabled = (this.m_Selected.Length > 0) && this.m_Selected[0].CanClipAndGameObjectBeEdited;
            if (AnimationUtility.InAnimationMode())
            {
                for (int j = 0; j < this.m_ShownProperties.Length; j++)
                {
                    AnimationWindow.vPosition = (int) this.m_ShownProperties[j].guiPosition.y;
                    float sampledOrCurveValue = this.m_ShownProperties[j].GetSampledOrCurveValue(this.time);
                    this.AnimationTextField(this.GetFieldRect((float) width), sampledOrCurveValue, j);
                }
            }
            else
            {
                for (int k = 0; k < this.m_ShownProperties.Length; k++)
                {
                    EditorGUI.GetControlID(s_AnimationTextFieldHash, FocusType.Passive, new Rect(0f, 0f, 0f, 0f));
                }
            }
            GUI.enabled = true;
            this.m_RemoveTextFieldFocus = false;
            AnimationWindow.vPosition = vPosition;
        }

        public void SelectProperties(CurveState first, int amount, bool additive)
        {
            int num = -1;
            for (int i = 0; i < this.m_ShownProperties.Length; i++)
            {
                if (this.m_ShownProperties[i] == first)
                {
                    num = i;
                    break;
                }
            }
            bool flag = true;
            for (int j = num; j < (num + amount); j++)
            {
                if (!this.m_SelectedProperties[j])
                {
                    flag = false;
                }
            }
            if (!additive)
            {
                for (int m = 0; m < this.m_ShownProperties.Length; m++)
                {
                    this.m_SelectedProperties[m] = false;
                }
            }
            for (int k = num; k < (num + amount); k++)
            {
                this.m_SelectedProperties[k] = !flag;
            }
            this.SetDirtyCurves();
        }

        public void SetAutoRecordMode(bool record)
        {
            if (this.m_AutoRecord != record)
            {
                if (record)
                {
                    record = this.EnsureAllHaveClips();
                }
                this.m_AutoRecord = record;
                foreach (AnimationSelection selection in this.m_Selected)
                {
                    selection.RefreshAutoRecordState();
                }
                if (this.m_AutoRecord)
                {
                    this.EnsureAnimationMode();
                }
            }
        }

        public void SetDirtyCurves()
        {
            this.m_DirtyCurves = true;
        }

        public void SetDirtyProperties()
        {
            if (!this.m_ShowAllProperties)
            {
                this.m_DirtyPropertyList = true;
            }
            this.m_DirtyProperties = true;
            this.m_DirtyCurves = true;
        }

        public void SetDirtyPropertyList()
        {
            this.m_DirtyPropertyList = true;
            this.m_DirtyProperties = true;
            this.m_DirtyCurves = true;
        }

        private void SetGridColors()
        {
            CurveEditorSettings settings = new CurveEditorSettings {
                hTickStyle = { distMin = 30, distFull = 80, distLabel = 0 }
            };
            if (EditorGUIUtility.skinIndex == 0)
            {
                settings.vTickStyle.color = new Color(1f, 1f, 1f, settings.vTickStyle.color.a);
                settings.vTickStyle.labelColor = new Color(1f, 1f, 1f, settings.vTickStyle.labelColor.a);
            }
            settings.vTickStyle.distMin = 15;
            settings.vTickStyle.distFull = 40;
            settings.vTickStyle.distLabel = 30;
            settings.vTickStyle.stubs = true;
            settings.hRangeMin = 0f;
            settings.hRangeLocked = false;
            settings.vRangeLocked = false;
            this.m_CurveEditor.settings = settings;
        }

        private void SetPlayMode(bool play)
        {
            if (play != this.m_PlayMode)
            {
                if (this.m_PlayMode)
                {
                    this.Stop();
                }
                else
                {
                    this.Play();
                }
            }
        }

        private void ShowButtonDropDown(Rect rect, int index)
        {
            int[] indices = new int[] { index };
            int[] linkedProperties = this.GetLinkedProperties(indices, false);
            int[] numArray3 = new int[] { index };
            int[] keyLinked = this.GetLinkedProperties(numArray3, true);
            this.GenerateMenu(linkedProperties, keyLinked).DropDown(rect);
            Event.current.Use();
        }

        private float SnapTimeToWholeFPS(float time)
        {
            return (Mathf.Round(time * this.m_FrameRate) / this.m_FrameRate);
        }

        private void Stop()
        {
            this.m_Frame = Mathf.RoundToInt(this.m_PlayTime * this.m_FrameRate);
            this.m_PlayMode = false;
            if (this.m_PlayFromNoMode)
            {
                this.EndAnimationMode();
            }
            else
            {
                this.ReEnterAnimationMode();
            }
            this.m_PlayFromNoMode = false;
        }

        private void TickAutoRecord()
        {
            if (!this.m_PlayMode && !EditorApplication.isPlaying)
            {
                bool flag = false;
                foreach (AnimationSelection selection in this.m_Selected)
                {
                    if (selection.CanClipAndGameObjectBeEdited)
                    {
                        flag |= selection.AutoRecord();
                    }
                }
                if (flag)
                {
                    this.SetDirtyProperties();
                    base.Repaint();
                }
            }
        }

        private void TimeLineGUI(Rect rect)
        {
            Color color = GUI.color;
            GUI.BeginGroup(rect);
            if (Event.current.type != EventType.Repaint)
            {
                GUI.EndGroup();
            }
            else
            {
                HandleUtility.handleWireMaterial.SetPass(0);
                GL.Begin(1);
                Color backgroundColor = GUI.backgroundColor;
                this.m_CurveEditor.hTicks.SetTickStrengths(3f, 80f, true);
                Color color3 = this.m_CurveEditor.settings.hTickStyle.color;
                color3.a = 0.75f;
                for (int i = 0; i < this.m_CurveEditor.hTicks.tickLevels; i++)
                {
                    float b = this.m_CurveEditor.hTicks.GetStrengthOfLevel(i) * 0.9f;
                    float[] numArray = this.m_CurveEditor.hTicks.GetTicksAtLevel(i, true);
                    for (int k = 0; k < numArray.Length; k++)
                    {
                        if (numArray[k] >= 0f)
                        {
                            int num4 = Mathf.RoundToInt(numArray[k] * this.m_FrameRate);
                            float num5 = (17f * Mathf.Min(1f, b)) * 0.7f;
                            GL.Color(new Color(1f, 1f, 1f, b / 0.5f) * color3);
                            GL.Vertex(new Vector3(this.FrameToPixel((float) num4, rect), (17f - num5) + 0.5f, 0f));
                            GL.Vertex(new Vector3(this.FrameToPixel((float) num4, rect), 16.5f, 0f));
                            if (b > 0.5f)
                            {
                                GL.Color(new Color(1f, 1f, 1f, (b / 0.5f) - 1f) * color3);
                                GL.Vertex(new Vector3(this.FrameToPixel((float) num4, rect) + 1f, (17f - num5) + 0.5f, 0f));
                                GL.Vertex(new Vector3(this.FrameToPixel((float) num4, rect) + 1f, 16.5f, 0f));
                            }
                        }
                    }
                }
                GL.End();
                int frameRate = (int) this.m_FrameRate;
                int length = frameRate.ToString().Length;
                int levelWithMinSeparation = this.m_CurveEditor.hTicks.GetLevelWithMinSeparation(40f);
                float[] ticksAtLevel = this.m_CurveEditor.hTicks.GetTicksAtLevel(levelWithMinSeparation, false);
                for (int j = 0; j < ticksAtLevel.Length; j++)
                {
                    if (ticksAtLevel[j] >= 0f)
                    {
                        int frame = Mathf.RoundToInt(ticksAtLevel[j] * this.m_FrameRate);
                        float num10 = Mathf.Floor(this.FrameToPixel((float) frame, rect));
                        string text = this.FormatFrame(frame, length);
                        GUI.Label(new Rect(num10 + 3f, -3f, 40f, 20f), text, ms_Styles.TimelineTick);
                    }
                }
                GUI.EndGroup();
                GUI.backgroundColor = backgroundColor;
                GUI.color = color;
            }
        }

        private float TimeToFrame(float time)
        {
            return (time * this.m_FrameRate);
        }

        private float TimeToPixel(float time, Rect rect)
        {
            return this.FrameToPixel(time * this.m_FrameRate, rect);
        }

        private void ToggleAnimationMode()
        {
            if (AnimationUtility.InAnimationMode())
            {
                Unsupported.SceneTrackerFlushDirty();
                bool flag = (this.m_GameObjectAndHierarchyChangeTracker != null) && this.m_GameObjectAndHierarchyChangeTracker.isDirty;
                this.EndAnimationMode();
                if (!flag && (this.m_GameObjectAndHierarchyChangeTracker != null))
                {
                    Unsupported.SceneTrackerFlushDirty();
                    this.m_GameObjectAndHierarchyChangeTracker.ClearDirty();
                }
            }
            else
            {
                this.BeginAnimationMode(true);
            }
            if (Toolbar.get != null)
            {
                Toolbar.get.Repaint();
            }
        }

        private void UndoRedoPerformed()
        {
            if (AnimationUtility.InAnimationMode())
            {
                this.PreviewFrame(this.m_Frame);
                foreach (AnimationSelection selection in this.m_Selected)
                {
                    selection.RefreshAutoRecordState();
                }
            }
            this.SetDirtyProperties();
            base.Repaint();
        }

        private void Update()
        {
            if (this.m_PlayMode)
            {
                this.m_PlayTime += Time.realtimeSinceStartup - this.m_PrevRealTime;
                this.m_PrevRealTime = Time.realtimeSinceStartup;
                if ((this.m_PlayTime * this.m_FrameRate) > Mathf.Min(this.maxFrame, (float) this.m_FinalFrame))
                {
                    this.m_PlayTime -= Mathf.Min(this.maxTime, ((float) this.m_FinalFrame) / this.m_FrameRate) - Mathf.Max(0f, this.minTime);
                }
                this.m_Frame = Mathf.RoundToInt(this.m_PlayTime * this.m_FrameRate);
                this.ResampleAnimation();
                base.Repaint();
            }
        }

        public void UpdateCurves(List<int> curveIds, string undoText)
        {
            for (int i = 0; i < this.m_ShownProperties.Length; i++)
            {
                CurveState state = this.m_ShownProperties[i];
                if (curveIds.Contains(state.GetID()))
                {
                    if (!state.animated)
                    {
                        state.animationSelection.EnsureClipPresence();
                    }
                    if (state.clip == null)
                    {
                        Debug.LogError("clip is null");
                    }
                    if (state.curveData == null)
                    {
                        Debug.LogError("curveData is null");
                    }
                    Undo.RegisterUndo(state.clip, undoText);
                    state.SaveCurve(state.curve);
                }
            }
            this.SetDirtyCurves();
        }

        public void UpdateFrame(int frame)
        {
            if (!this.m_PlayMode && AnimationUtility.InAnimationMode())
            {
                this.PreviewFrame(frame);
            }
        }

        public void UpdateTime(float time)
        {
            if (!this.m_PlayMode && AnimationUtility.InAnimationMode())
            {
                this.m_Frame = Mathf.RoundToInt(this.TimeToFrame(time));
                this.PreviewFrame(this.m_Frame);
            }
        }

        public void UseEulerAnglesInterpolation(object obj)
        {
            List<int> propertyIndices = (List<int>) obj;
            this.ChangeRotationInterpolationType(propertyIndices, true);
        }

        public void UseQuaternionInterpolation(object obj)
        {
            List<int> propertyIndices = (List<int>) obj;
            this.ChangeRotationInterpolationType(propertyIndices, false);
        }

        public SerializedStringTable chosenAnimated
        {
            get
            {
                return this.m_ChosenAnimated;
            }
            set
            {
                this.m_ChosenAnimated = value;
            }
        }

        public SerializedStringTable chosenClip
        {
            get
            {
                return this.m_ChosenClip;
            }
            set
            {
                this.m_ChosenClip = value;
            }
        }

        public SerializedStringTable expandedFoldouts
        {
            get
            {
                return this.m_ExpandedFoldouts;
            }
            set
            {
                this.m_ExpandedFoldouts = value;
            }
        }

        private float frameSpan
        {
            get
            {
                return (this.m_CurveEditor.shownArea.width * this.m_FrameRate);
            }
        }

        private float maxFrame
        {
            get
            {
                return (this.m_CurveEditor.shownArea.xMax * this.m_FrameRate);
            }
        }

        private float maxTime
        {
            get
            {
                return this.m_CurveEditor.shownArea.xMax;
            }
        }

        private float minFrame
        {
            get
            {
                return (this.m_CurveEditor.shownArea.xMin * this.m_FrameRate);
            }
        }

        private float minTime
        {
            get
            {
                return this.m_CurveEditor.shownArea.xMin;
            }
        }

        public bool showAllProperties
        {
            get
            {
                return this.m_ShowAllProperties;
            }
        }

        public float time
        {
            get
            {
                return this.FrameToTime((float) this.m_Frame);
            }
        }

        public float timeCeiling
        {
            get
            {
                return this.FrameToTimeCeiling((float) this.m_Frame);
            }
        }

        public float timeFloor
        {
            get
            {
                return this.FrameToTimeFloor((float) this.m_Frame);
            }
        }

        private float timeSpan
        {
            get
            {
                return this.m_CurveEditor.shownArea.width;
            }
        }

        public class EventComparer : IComparer
        {
            int IComparer.Compare(object objX, object objY)
            {
                AnimationEvent event2 = (AnimationEvent) objX;
                AnimationEvent event3 = (AnimationEvent) objY;
                float time = event2.time;
                float num2 = event3.time;
                if (time != num2)
                {
                    return (int) Mathf.Sign(time - num2);
                }
                int hashCode = event2.GetHashCode();
                int num4 = event3.GetHashCode();
                return (hashCode - num4);
            }
        }

        private class EventLineContextMenuObject
        {
            public GameObject m_Animated;
            public AnimationClip m_Clip;
            public float m_Time;

            public EventLineContextMenuObject(GameObject animated, AnimationClip clip, float time)
            {
                this.m_Animated = animated;
                this.m_Clip = clip;
                this.m_Time = time;
            }
        }

        internal class Styles
        {
            public GUIContent addEventContent = EditorGUIUtility.IconContent("Animation.AddEvent");
            public GUIContent addKeyframeContent = EditorGUIUtility.IconContent("Animation.AddKeyframe");
            public GUIStyle curveEditorBackground = "AnimationCurveEditorBackground";
            public GUIStyle eventBackground = "AnimationEventBackground";
            public GUIStyle keyframeBackground = "AnimationKeyframeBackground";
            public GUIStyle miniToolbarButton = "MiniToolbarButtonLeft";
            public GUIStyle miniToolbarPopup = "MiniToolbarPopup";
            public GUIContent nextKeyContent = EditorGUIUtility.IconContent("Animation.NextKey");
            public GUIContent playContent = EditorGUIUtility.IconContent("Animation.Play");
            public Texture2D pointIcon = EditorGUIUtility.LoadIcon("animationkeyframe");
            public GUIContent prevKeyContent = EditorGUIUtility.IconContent("Animation.PrevKey");
            public GUIContent recordContent = EditorGUIUtility.IconContent("Animation.Record");
            public GUIStyle rowEven = "AnimationRowOdd";
            public GUIStyle rowOdd = "AnimationRowEven";
            public GUIStyle TimelineTick = "AnimationTimelineTick";
        }
    }
}

